﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using sample.Models;

namespace sample.Controllers
{
    public class HomeController : Controller
    {
        DB_First_WebEntities db = new DB_First_WebEntities();
        public ActionResult Index()
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";

            return View();
        }

        public ActionResult About()
        {
            return View();
        }
        public ActionResult Ckeditor()
        {
            return View();
        }

        public ActionResult datetimePicker()
        {
            return View();
        }
        
        

        [HttpPost, ValidateInput(false)]
        public ActionResult Ckeditor(tbd_News news )
        {

            db.tbd_News.AddObject(news);
            db.SaveChanges();


            


            return RedirectToAction("ViewNews");
        }
        public ActionResult ViewNews()
        {
            List<tbd_News> newss = db.tbd_News.ToList();
            return View(newss[0]);
        }
         public ActionResult PagedList(int? page)
        {

           
             
            PagedList<tbd_News> newss = db.tbd_News.ToPagedList(page??1,3);
                
          

            return View(newss);
          
        }
    }
}
